<?php
	include 'ZionHeader.inc';
?>
<HTML>
<head>
<title>ZionsAuto</title>

	<?php
		$name = $_SESSION['UName'];
		$password = $_POST['password'];
		
		
		//Need to compare $name with username of announcement
	?>

  <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<BODY>
<h1><center>Bookmarks</center></h1>

<!-- Tab Menu Goes here -->
<div id="tabs">
  <ul>
    <li><a href="homePage.php"><span>Home</span></a></li>
    <li><a href="Browse.php"><span>Browse</span></a></li>
	<li><a href="announcement.php"><span>Announcements</span></a></li>
	<?php
	$AccountType = $_SESSION['AType'];
	if ($AccountType == 'R')
	{
		echo "<li><a href='editProfile.php'><span>Edit Profile</span></a></li>";
	}
	?>
    <li><a href="logout.php"><span>Log Out</span></a></li>
  </ul>
</div>

<?php

	$AccountType = $_SESSION['AType'];
	include 'DatabaseConnect.inc';
	
	//Grab announcementID from Bookmark table 
	$query = "SELECT * FROM Bookmark WHERE User_LoginID = '$name'";
	$result = mysql_query($query);

	echo "<table border='1'>";
	echo "<tr>  <th>Make</th> <th>Model</th> <th>Year</th> <th>Price</th> <th>VIN</th> <th>Cylinder</th> <th>Drive</th> <th>Color</th> <th>Description</th> <th>Mileage</th> <th>Number of Doors</th> <th>Photo</th>";
	
	
	// keeps getting the next row until there are no more to get
	while($row = mysql_fetch_array( $result, MYSQL_ASSOC )) 
	{
		$announcementID = $row['announceID'];
		
		$query = "SELECT * FROM Announcement WHERE ID = '$announcementID'";
		$result2 = mysql_query($query);
		
		$row2 = mysql_fetch_array($result2);
		
		$vehicleID = $row2['vehicle_ID'];
		
		$query = "SELECT * FROM Vehicle WHERE ID = '$vehicleID'";
		$result3 = mysql_query($query);
		$row3 = mysql_fetch_array($result3);

		echo "<tr><td>"; 
		echo $row3['Make'];
		echo "</td><td>"; 
		echo $row3['Model'];
		echo "</td><td>"; 
		echo $row3['Year'];
		echo "</td><td>"; 
		echo $row3['Price'];
		echo "</td><td>"; 
		echo $row3['VIN'];
		echo "</td><td>"; 
		echo $row3['Cylinder'];
		echo "</td><td>"; 
		echo $row3['Drive'];
		echo "</td><td>"; 
		echo $row3['Color'];
		echo "</td><td>"; 
		echo $row3['Description'];
		echo "</td><td>"; 
		echo $row3['Mileage'];
		echo "</td><td>"; 
		echo $row3['NoDoors'];
		echo "</td><td>";
		echo "<img src='viewimage.php?id=".$row3['ID']."' width=250 height=200>";
		echo "</td><td>";
		
			
				echo "</td><td>";
				echo "<form action='deleteBookmark.php' method='POST'>";
				echo "    <input type='hidden' name='ID' value = ".$row3['ID']." />";
				echo "    <input type='submit' name='Submit' value ='Delete Bookmark'/>";
				echo "</form>";
			
		
		
		echo "</td></tr>";
	}
	
	echo "</table>";
	
	mysql_close();

?>

<!-- Footer Goes Here -->
<div id="footer">
<hr>
<P>(C)Copyright 2011 Zion's DBA. All Rights Reserved</P>
</div>

</BODY>
</HTML>